//
//  DZGuidePageView.m
//  dzyc
//
//  Created by 蓝鳍互娱 on 2024/6/11.
//

#import "DZGuidePageView.h"
@interface DZGuidePageView()
@property (nonatomic, strong)UIImageView * guidePageImgView;
@property (nonatomic, strong)NSArray * guidePageImgs;
@property (nonatomic, assign)int guidePageIndex;
@end
@implementation DZGuidePageView
-(instancetype)init{
    if(self == [super init]){
        self.guidePageIndex = 0;
        self.guidePageImgs = @[@"guidePage_1",@"guidePage_2",@"guidePage_3"];
        [self makeGuidePage];
    }
    return self;
}
- (void)makeGuidePage{
    self.guidePageImgView = [[UIImageView alloc] init];
    self.guidePageImgView.userInteractionEnabled = YES;
    self.guidePageImgView.image = DZImageNamed(self.guidePageImgs[self.guidePageIndex]);
    [self addSubview:self.guidePageImgView];
    [self.guidePageImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(@(DZRatio(0)));
    }];
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapStep)];
    [self addGestureRecognizer:tap];
}
- (void)tapStep{
    self.guidePageIndex ++;
    if(self.guidePageImgs.count > self.guidePageIndex){
        self.guidePageImgView.image = DZImageNamed(self.guidePageImgs[self.guidePageIndex]);
    }else{
        DZ_SETObject_UserDef(NSUserDefaults_First, @"1");
        if(self.ClearGuideBlock){
            self.ClearGuideBlock();
        }
        [self removeFromSuperview];
    }
}
@end
